<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/product.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="location = '<?php echo $insert; ?>'" class="button"><?php echo $button_insert; ?></a></div>
    </div>
    <div class="content">
      <form action="#" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td class="center"><?php echo $column_image; ?></td>
              <td class="left"><?php echo $column_name; ?></td>
              <td class="left"><?php if ($sort == 'pd.display_name') { ?>
                <a href="<?php echo $sort_name; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_display_name; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_name; ?>"><?php echo $column_display_name; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.ean') { ?>
                <a href="<?php echo $sort_ean; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_ean; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_ean; ?>"><?php echo $column_ean; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.model') { ?>
                <a href="<?php echo $sort_model; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_model; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_model; ?>"><?php echo $column_model; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.price') { ?>
                <a href="<?php echo $sort_price; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_price; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_price; ?>"><?php echo $column_price; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.quantity') { ?>
                <a href="<?php echo $sort_quantity; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_quantity; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_quantity; ?>"><?php echo $column_quantity; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.status') { ?>
                <a href="<?php echo $sort_status; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_status; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_status; ?>"><?php echo $column_status; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'p.sort_order') { ?>
                <a href="<?php echo $sort_sort_order; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_sort_order; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_sort_order; ?>"><?php echo $column_sort_order; ?></a>
                <?php } ?></td>
              <td class="right"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>
            <tr class="filter">
              <td></td>
              <td></td>
              <td><input type="text" name="filter_name" value="<?php echo $filter_name; ?>" /></td>
              <td><input type="text" name="filter_ean" value="<?php echo $filter_ean; ?>" size="12"/></td>
              <td><input type="text" name="filter_model" value="<?php echo $filter_model; ?>" size="12"/></td>
              <td><input type="text" name="filter_price_min" value="<?php echo $filter_price_min; ?>" size="3"/>--
              	<input type="text" name="filter_price_max" value="<?php echo $filter_price_max; ?>" size="3"/></td>
              <td><input type="text" name="filter_quantity_min" value="<?php echo $filter_quantity_min; ?>" size="3"/>--
              	<input type="text" name="filter_quantity_max" value="<?php echo $filter_quantity_max; ?>" size="3"/></td>
              <td><select name="filter_status">
                  <option value="-1" <?php if ($filter_status == -1) { echo 'selected=\"selected\"'; }?>>--</option>
                  <option value="0" <?php if ($filter_status == 0) { echo 'selected=\"selected\"'; }?>><?php echo $text_disabled; ?></option>
                  <option value="1" <?php if ($filter_status == 1) { echo 'selected=\"selected\"'; }?>><?php echo $text_enabled; ?></option>
                </select></td>
              <td></td>
              <td align="right"><a onclick="filter();" class="button"><?php echo $button_filter; ?></a></td>
            </tr>
            <?php if ($products) { ?>
            <?php foreach ($products as $product) { ?>
            <tr>
              <td class="center"><img src="<?php echo $product['image']; ?>" alt="<?php echo $product['name']; ?>" style="padding: 1px; border: 1px solid #DDDDDD;" /></td>
              <td class="left"><?php echo $product['name']; ?></td>
              <td class="left"><?php echo $product['display_name']; ?></td>
              <td class="left"><?php echo $product['ean']; ?></td>
              <td class="left"><?php echo $product['model']; ?></td>
              <td class="left"><?php echo $product['price']; ?></td>
              <td class="left"><?php if ($product['quantity'] <= 0) { ?>
                <span style="color: #FF0000;"><?php echo $product['quantity']; ?></span>
                <?php } elseif ($product['quantity'] <= 5) { ?>
                <span style="color: #FFA500;"><?php echo $product['quantity']; ?></span>
                <?php } else { ?>
                <span style="color: #008000;"><?php echo $product['quantity']; ?></span>
                <?php } ?></td>
              <td class="left"><?php echo $product['status']; ?></td>
              <td class="left"><?php echo $product['sort_order']; ?></td>
              <td class="right"><?php foreach ($product['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="10"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=product/product&token=<?php echo $token; ?>';
	var filter_name = $('input[name=\'filter_name\']').attr('value');
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}
	var filter_ean = $('input[name=\'filter_ean\']').attr('value');
	if (filter_ean) {
		url += '&filter_ean=' + encodeURIComponent(filter_ean);
	}
	var filter_model = $('input[name=\'filter_model\']').attr('value');
	if (filter_model) {
		url += '&filter_model=' + encodeURIComponent(filter_model);
	}
	var filter_price_min = $('input[name=\'filter_price_min\']').attr('value');
	if (filter_price_min) {
		url += '&filter_price_min=' + encodeURIComponent(filter_price_min);
	}
	var filter_price_max = $('input[name=\'filter_price_max\']').attr('value');
	if (filter_price_max) {
		url += '&filter_price_max=' + encodeURIComponent(filter_price_max);
	}
	var filter_quantity_min = $('input[name=\'filter_quantity_min\']').attr('value');
	if (filter_quantity_min) {
		url += '&filter_quantity_min=' + encodeURIComponent(filter_quantity_min);
	}
	var filter_quantity_max = $('input[name=\'filter_quantity_max\']').attr('value');
	if (filter_quantity_max) {
		url += '&filter_quantity_max=' + encodeURIComponent(filter_quantity_max);
	}
	var filter_status = $('select[name=\'filter_status\']').attr('value');
	if (filter_status != '-1') {
		url += '&filter_status=' + encodeURIComponent(filter_status);
	}	
	location = url;
}
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script>
<?php echo $footer; ?>